package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.TDoctorClass;
import com.ruoyi.project.system.service.ITDoctorClassService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 医生分类关联表Controller
 * 
 * @author 孙山伟
 * @date 2020-12-20
 */
@RestController
@RequestMapping("/system/doctorclass")
public class TDoctorClassController extends BaseController
{
    @Autowired
    private ITDoctorClassService tDoctorClassService;

    /**
     * 查询医生分类关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:doctorclass:list')")
    @GetMapping("/list")
    public TableDataInfo list(TDoctorClass tDoctorClass)
    {
        startPage();
        List<TDoctorClass> list = tDoctorClassService.selectTDoctorClassList(tDoctorClass);
        return getDataTable(list);
    }

    /**
     * 导出医生分类关联表列表
     */
    @PreAuthorize("@ss.hasPermi('system:doctorclass:export')")
    @Log(title = "医生分类关联表", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(TDoctorClass tDoctorClass)
    {
        List<TDoctorClass> list = tDoctorClassService.selectTDoctorClassList(tDoctorClass);
        ExcelUtil<TDoctorClass> util = new ExcelUtil<TDoctorClass>(TDoctorClass.class);
        return util.exportExcel(list, "doctorclass");
    }

    /**
     * 获取医生分类关联表详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:doctorclass:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(tDoctorClassService.selectTDoctorClassById(id));
    }

    /**
     * 新增医生分类关联表
     */
    @PreAuthorize("@ss.hasPermi('system:doctorclass:add')")
    @Log(title = "医生分类关联表", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TDoctorClass tDoctorClass)
    {
        return toAjax(tDoctorClassService.insertTDoctorClass(tDoctorClass));
    }

    /**
     * 修改医生分类关联表
     */
    @PreAuthorize("@ss.hasPermi('system:doctorclass:edit')")
    @Log(title = "医生分类关联表", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TDoctorClass tDoctorClass)
    {
        return toAjax(tDoctorClassService.updateTDoctorClass(tDoctorClass));
    }

    /**
     * 删除医生分类关联表
     */
    @PreAuthorize("@ss.hasPermi('system:doctorclass:remove')")
    @Log(title = "医生分类关联表", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tDoctorClassService.deleteTDoctorClassByIds(ids));
    }
}
